#!/bin/bash

passes=0
fails=0
i=1

echo ""
echo ""
echo "Running LaTeXCalc test suite..."
echo ""


for i in *".tin"
do

  i=${i%%.tin}
  ../build/latexcalc < $i.tin > $i.tex 2> $i.tmp

  DIFF1=`diff $i.tex $i.out`
  DIFF2=`diff $i.tmp $i.err`

  if [ "$DIFF1" != "" -o  ! -f $i.tex  -o  ! -f $i.out  ]; then
	echo "Test $i A Failed!"
	let fails=$fails+1 
  else
	echo "Test $i A Passed!"
	let passes=$passes+1
  fi

  if [ "$DIFF2" != "" -o  ! -f $i.tmp  -o  ! -f $i.err  ]; then
	echo "Test $i B Failed!"
	let fails=$fails+1
  else
	echo "Test $i B Passed!"
	let passes=$passes+1
  fi
done
	
let total=$fails+$passes
let percent=100*$passes/total

echo ""
echo ""
echo ""
echo "SUMMARY:"
echo "$passes/$total tests passed ($percent%). $fails tests failed."
echo ""
echo ""
echo ""
